package com.example.service.impl;
import java.math.BigDecimal;
import java.util.concurrent.TimeUnit;

import com.example.entity.Product;
import com.example.service.ProductService;
import org.springframework.stereotype.Service;

@Service
public class ProductServiceImpl implements ProductService {
    @Override
    public Product getProductById(Long id) {
        Product product = new Product();
        product.setId(id);
        product.setPrice(new BigDecimal("99"));
        product.setProductName("Iphone");
        product.setNum(2);

        // 测试异常熔断
//        int i = 10/0;
//        try {
////               模拟服务器超时
//            // 服务休眠时间，休眠100s后返回数据
//            TimeUnit.SECONDS.sleep(2);
//        } catch (InterruptedException e) {
//            throw new RuntimeException(e);
//        }
        return product;
    }
}
